
using System;
using System.Collections.Generic;
using BTKERP.Model;
using BTKERP.DAL.DataAccess;
using System;

namespace BTKERP.DAL
{
	#region RequisitionDeliveryDetailDAL
	public class RequisitionDeliveryDetailDAL : DBContext
	{
		public List<RequisitionDeliveryDetail> GetAll()
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_RequisitionDeliveryDetailsSelectAll");
            return GetEntityList<RequisitionDeliveryDetail>(cmd);
        }

        public List<RequisitionDeliveryDetail> GetByMasterId(Guid masterId)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_RequisitionDeliveryDetailSelect");
            cmd.AddParameter("@RequisitionDeliveryId", masterId);
            return GetEntityList<RequisitionDeliveryDetail>(cmd);
        }

		public List<RequisitionDeliveryDetail> GetByDynamicSQL(string sqlCondition)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_RequisitionDeliveryDetailSelectDynamic");
            cmd.AddParameter("@SQL", sqlCondition);
            return GetEntityList<RequisitionDeliveryDetail>(cmd);
        }

        public RequisitionDeliveryDetail Add(Guid paramRequisitionDeliveryId, Guid paramProductId, Guid paramUnitId,
                                                    decimal paramUnitPrice, decimal paramDeliveryQuantity, decimal paramReceivedQuantity,
                                                    decimal paramDeliveredTotal, decimal paramReceivedTotal, string paramStatus, string paramCreatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_RequisitionDeliveryDetailInsert");
            cmd.AddParameter("@RequisitionDeliveryId", paramRequisitionDeliveryId);
            cmd.AddParameter("@ProductId", paramProductId);
            cmd.AddParameter("@UnitId", paramUnitId);
            cmd.AddParameter("@UnitPrice", paramUnitPrice);
            cmd.AddParameter("@DeliveryQuantity", paramDeliveryQuantity);
            cmd.AddParameter("@ReceivedQuantity", paramReceivedQuantity);
            cmd.AddParameter("@DeliveredTotal", paramDeliveredTotal);
            cmd.AddParameter("@ReceivedTotal", paramReceivedTotal);
            cmd.AddParameter("@Status", paramStatus);
            cmd.AddParameter("@CreatedBy", paramCreatedBy);
            return GetSingleEntity<RequisitionDeliveryDetail>(cmd);
        }
		
        public bool DeleteById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_RequisitionDeliveryDetailDelete");
            cmd.AddParameter("@Id", id);
            return ExecuteCommand(cmd);
        }

        public RequisitionDeliveryDetail UpdateById(Guid paramRequisitionDeliveryId, Guid paramProductId, Guid paramUnitId,
                                                    decimal paramUnitPrice,	decimal paramDeliveryQuantity, 	decimal paramReceivedQuantity,
                                                    decimal paramDeliveredTotal, decimal paramReceivedTotal, string paramStatus, string paramUpdatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_RequisitionDeliveryDetailUpdate");
			cmd.AddParameter("@RequisitionDeliveryId", paramRequisitionDeliveryId);
			cmd.AddParameter("@ProductId", paramProductId);
			cmd.AddParameter("@UnitId", paramUnitId);
			cmd.AddParameter("@UnitPrice", paramUnitPrice);
			cmd.AddParameter("@DeliveryQuantity", paramDeliveryQuantity);
			cmd.AddParameter("@ReceivedQuantity", paramReceivedQuantity);
			cmd.AddParameter("@DeliveredTotal", paramDeliveredTotal);
			cmd.AddParameter("@ReceivedTotal", paramReceivedTotal);
			cmd.AddParameter("@Status", paramStatus);
			cmd.AddParameter("@UpdatedBy", paramUpdatedBy);
            return GetSingleEntity<RequisitionDeliveryDetail>(cmd);
        }
		
	}
	#endregion
}
